package com.ling.payservice.controller;

import com.alipay.api.AlipayApiException;
import com.ling.payservice.service.AliPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/WxPay")
public class AliPayController {

    @Autowired
    AliPayService aliPayService;

    @GetMapping("testPay")
    public Map<String,Object> test() throws AlipayApiException {
        return aliPayService.ScanQRcode();
    }


    /**
     * 支付宝支付，用户被扫，出示付款码
     * @param totalAmount 支付金额
     * @param code 付款码
     * @return
     * @throws AlipayApiException
     */
    @GetMapping("QRScan")
    public Map<String,Object> QRSCan(String totalAmount,String code) throws AlipayApiException {
      return   aliPayService.QRScan(totalAmount,code);
    }
}
